import type { App } from 'vue'
import {
    // default as coreApi,
    apis as coreApis,
    disposeApiModulesByRequireContext
} from '@jsjn/micro-core-api'

// 本地模块
const localApis = disposeApiModulesByRequireContext(
    require.context('./modules', false, /\.api\.ts$/)
)

// 汇总
export const apis = Object.assign({}, localApis, coreApis)

// 注册（历史遗留问题，需要在 app 实例上注册 apis）
export default (app: App) => {
    app.config.globalProperties.$api = apis
}
